﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SoundRSEditor
{
    // https://ccrma.stanford.edu/courses/422/projects/WaveFormat/ is a good link
    class SoundEffect
    {
        byte[] data;
        UInt32 offset;

        public UInt32 Offset
        {
            get { return offset; }
        }
        UInt32 size;

        public UInt32 Size
        {
            get { return size; }
        }

        public int AudioFormat
        {
            get
            {
                //byte[] copy = new byte[2];
                //Array.Copy(data, 20, copy, 0, 2);
                return (int)BitConverter.ToUInt16(data, 20);
            }
        }
        public int NumChannels
        {
            get
            {
                return (int)BitConverter.ToUInt16(data, 22);
            }
        }
        public int SampleRate
        {
            get
            {
                return (int)BitConverter.ToUInt32(data, 24);
            }
        }
        public byte[] Data
        {
            get { return data; }
            set { data = value; }
        }
        public SoundEffect(UInt32 offset, UInt32 size)
        {
            this.offset = offset;
            this.size = size;
        }
        public void UpdateSize()
        {
            size = (uint)data.Length;
        }
    }
}
